#include <cstdio>
#include <cctype>

#define MAX_S 100002
#define MAX_T 1002


inline int get_int (int &n)
{
	return scanf ("%d\n", &n);
}


inline bool is_substring (const char *s, const char *t)
{
	for (; isalpha (*t); ++t, ++s)
	{
		if (*s != *t)
			return false;
	}
	return true;
}


inline const char * substring (const char *s, const char *t)
{
	for (; isalpha (*s); ++s)
	{
		if (is_substring (s, t))
			return s;
	}
	return 0;
}


int main ()
{
	char s[MAX_S], t[MAX_T];
	int test_cases, q;

	get_int (test_cases);
	while (--test_cases >= 0)
	{
		fgets (s, MAX_S, stdin);
		get_int (q);
		while (--q >= 0)
		{
			fgets (t, MAX_T, stdin);
			putchar (substring (s, t) ? 'y' : 'n');
			putchar ('\n');
		}
	}

	return 0;
}